<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="container1">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div>111</div>
        <div>222</div>
        <div>333</div>
    </div>
    <script>

        var btns = document.querySelectorAll(".container1 button");
        var divs = document.querySelectorAll(".container1 div");

        btns.forEach((btn,key)=>{
            btn.onclick = function(){
                divs.forEach((div,k)=>{
                    if(k==key){
                        divs[k].style.display = "block";
                    }else{
                        divs[k].style.display = "none";
                    }
                })
            }
        })


    </script>
</body>

</html>